//
//  WBHomeController.swift
//  WeiBo
//
//  Created by lihaixing on 2018/11/29.
//  Copyright © 2018年 lihaixing. All rights reserved.
//

import UIKit
   private let cellID="cellID"
class WBHomeController: WBBaseViewController {


   private lazy var statusList = [String]()
    
    
    @objc func pushFriends() {
        let vc=WBDemoViewController()
        navigationController?.pushViewController(vc, animated: true)
    }
//    重写父类，加载列表数据
    override func loadData() {
        for i in 0..<18 {
            statusList.insert(i.description, at: 0)
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

// MARK: UITableViewDelegate&Datasource
extension WBHomeController{
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return statusList.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let  cell = tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath)
        
        cell.textLabel?.text=statusList[indexPath.row]
        return cell
        
    }
}

extension WBHomeController{
    override func setupUI() {
        super.setupUI()
//        navigationItem.leftBarButtonItem=UIBarButtonItem.init(title: "好友", style: .plain, target: self, action: #selector(pushFriends))
        
//        抽取类似代码到扩展
//        let btn:UIButton=UIButton.cz_textButton("好友", fontSize: 16, normalColor: UIColor.gray, highlightedColor: UIColor.orange)
//        btn .addTarget(self, action:#selector(pushFriends) , for: .touchUpInside)
//        navigationItem.leftBarButtonItem=UIBarButtonItem.init(customView: btn)
        naviItem.leftBarButtonItem=UIBarButtonItem.init(title: "好友", target: self, action: #selector(pushFriends))
        tableView?.register(UITableViewCell.self, forCellReuseIdentifier: cellID)
        
        
        
        
    }

}
